package com.sgb.businessmodule.entity;

import com.google.gson.annotations.SerializedName;

import java.io.Serializable;
import java.util.Objects;

public class PickFilterEntity<T> implements Serializable {

    //@SerializedName(value = "no", alternate = {""})
    private String no;

    @SerializedName(value = "name", alternate = {"simpleName"})
    private String name;


    public PickFilterEntity() {

    }
    public PickFilterEntity(String no, String name) {
        this.no = no;
        this.name = name;
    }

    @SerializedName(value = "children", alternate = {"child"})
    private T children;

    private boolean isChoose;//非服务器字段， 用于保存item的状态

    public boolean isChoose() {
        return isChoose;
    }

    public void setChoose(boolean choose) {
        isChoose = choose;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public T getChildren() {
        return children;
    }

    public void setChildren(T children) {
        this.children = children;
    }

    @Override
    public String toString() {
        return "PickFilterEntity{" +
                "no='" + no + '\'' +
                ", name='" + name + '\'' +
                ", children=" + children +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PickFilterEntity<?> that = (PickFilterEntity<?>) o;
        return Objects.equals(no, that.no) &&
                Objects.equals(name, that.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(no, name);
    }

    public void clearData(){
        this.no = "";
        this.name = "";
    }

    public void replaceData(PickFilterEntity entity){
        this.no = entity.getNo();
        this.name = entity.getName();
    }
}
